package com.bicon.botu.mall.component.entity;

import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableName;
import com.bicon.botu.core.base.repository.mybatis.UuidBaseEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.util.HashMap;
import java.util.Map;

/**
 * 首页服务定义
 *
 * @author 王开亮
 * @date 2018/2/24 9:26
 */
@EqualsAndHashCode(callSuper = true)
@Data
@TableName("home_functions")
@AllArgsConstructor
@NoArgsConstructor
public class HomeFunctions extends UuidBaseEntity<HomeFunctions> {

    /**
     * 服务名称
     */
    @TableField("name")
    private String name;

    /**
     * 服务Code
     */
    @TableField("code")
    private String code;

    /**
     * 图标URL
     */
    @TableField("icon_url")
    private String iconUrl;

    /**
     * 参数
     */
    @TableField("params")
    private String params;

    /**
     * 状态1：开启 0：关闭
     */
    @TableField("status")
    private Integer status;

    public Map<String,String> toMap(){
        Map<String,String> result = new HashMap<>();
        result.put("id",this.getId());
        result.put("name",this.getName());
        result.put("code",this.getCode());
        result.put("iconUrl",this.getIconUrl());
        result.put("params",this.getParams());
        result.put("status",this.getStatus()==null?"0":this.getStatus().toString());
        return result;
    }

    public void fromMap(Map<String, String> map) {
        this.setId(map.get("id"));
        this.setName(map.get("name"));
        this.setCode(map.get("code"));
        this.setIconUrl(map.get("iconUrl"));
        this.setParams(map.get("params"));
        this.setStatus(Integer.valueOf(map.get("status")));
    }


}
